package com.anzxy.home.controller;

import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.GetMapping;
import com.anzxy.home.service.IHomeTallyBookService;
import com.anzxy.heart.core.ResponseResult;
import com.anzxy.home.entity.HomeTallyBook;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import java.util.List;

/**
 * <p>
 * 家庭记账本 前端控制器
 * </p>
 *
 * @author ZQ
 * @since 2024-12-27
 */
@RestController
@RequestMapping("/home/home-tally-book")
public class HomeTallyBookController {
    private IHomeTallyBookService service;
    
    public HomeTallyBookController(IHomeTallyBookService service) {
        this.service = service;
    }

    @PostMapping("submit")
    public ResponseResult add(@RequestBody HomeTallyBook entity) {
        this.service.submit(entity);
        return ResponseResult.success();
    }

    @PostMapping("delete")
    public ResponseResult delete(@RequestBody List<Integer> ids) {
        this.service.delete(ids);
        return ResponseResult.success();
    }

    @GetMapping("page")
    public ResponseResult page(Page<HomeTallyBook> page, HomeTallyBook query) {
        final Page<HomeTallyBook> pageResult = this.service.page(page,query);
        return ResponseResult.success(pageResult);
    }
}
